package top.lywivan.linkedlist;

import top.lywivan.linkedlist.inf.List;

/**
 * @author :lyw.ivan
 * @date :Created in 2022/5/29
 * @description :
 * @version: 1.0
 */
public class LinkedListTest {
    public static void main(String[] args) {
        List list = new LinkedList();
        list.add(1);
        list.add(2);
        list.add(3);
        System.out.println("容器内元素为:"+list); // 1‐>2‐>3‐>Null
        System.out.println("容器内元素个数:"+list.size()+"容器是否为空:"+list.isEmpty());
        System.out.println("容器中是否包含3:"+list.contains(3));
        list.add(0,4);// 4‐>1‐>2‐>3‐>Null
        System.out.println("容器内元素为:"+list);
        list.add(3,5);//4‐>1‐>2‐>5‐>3‐>Null
        System.out.println("容器内元素为:"+list);
        list.add(2,6);//4‐>1‐>6‐>2‐>5‐>3‐>Null
        System.out.println("容器内元素为:"+list);
        System.out.println("获取索引为0的元素:"+list.get(0));
        System.out.println("获取索引为5的元素:"+list.get(5));
        System.out.println("获取索引为2的元素:"+list.get(2));
        list.remove(0);//1‐>6‐>2‐>5‐>3‐>Null
        System.out.println("容器内元素为:"+list);
        list.remove(3);//1‐>6‐>2‐>3‐>Null
        System.out.println("移除后容器内元素为:"+list);
        list.clear();
        System.out.println("清空后为:"+list);
    }
}
